function oRequest_LocalStorageEngine(engine) {
  this.engine = engine;
}

oRequest_LocalStorageEngine.prototype = {
  set: function (key, value) {
    let storage = window.localStorage;
    //写入a字段
    //storage["a"]=1;
    //写入b字段
    //storage.key=value;
    //写入c字段
    storage.setItem(key, this.engine.tools.base64.encode(JSON.stringify(value)));
    return true;
  },
  get: function (key) {
    let storage = window.localStorage;
    //第一种方法读取
    //var a=storage.a;
    //console.log(a);
    //第二种方法读取
    //var b=storage["b"];
    //console.log(b);
    //第三种方法读取
    let value = storage.getItem(key);
    if (!this.engine.tools.IsNullOrEmpty(value)) {
      value = this.engine.tools.base64.decode(value);
      return JSON.parse(value);
    }
    // 因为封装以后LocalStorage存储的都是对象，所以返回null比较合适。
    return null;
  },
  remove: function (key) {
    let storage = window.localStorage;
    try {
      storage.removeItem(key);
      return true;
    } catch (e) {
      return false;
    }
  },
}

export {
  oRequest_LocalStorageEngine
}


